﻿import random


def gen_header(width, height):
    print(
        f"""<svg xmlns="http://www.w3.org/2000/svg" version="1.1" subset="wps" height="{height}" width="{width}"> <rect x="0" y="0" width="1111" height="888" stroke="rgb(255, 255, 255, 1)" stroke-width="2" fill="rgb(255, 255, 255, 1)" />""")


def gen_rect(x, y, width,  height):
    print(f"""<rect x="{x}" y="{y}" width="{width}" height="{height}" stroke="rgb(0, 0, 0, 1)" stroke-width="2" fill="rgb(255, 255, 255, 0)" />""")


def gen_line(x1, y1, x2, y2, width=2):
    print(
        f"""<line x1="{x1}" y1="{y1}" x2="{x2}" y2="{y2}" stroke="rgb(0, 0, 0, 1)" stroke-width="{width}"/>""")


def gen_random_line(canvas_width, canvas_height):
    x1 = random.randint(0, canvas_width)
    y1 = random.randint(0, canvas_height)
    x2 = random.randint(0, canvas_width)
    y2 = random.randint(0, canvas_height)
    gen_line(x1, y1, x2, y2)


def gen_random_rect(canvas_width, canvas_height):
    x = random.randint(0, canvas_width)
    y = random.randint(0, canvas_height)
    width = random.randint(0, canvas_width - x)
    height = random.randint(0, canvas_height - y)
    gen_rect(x, y, width, height)


def gen():
    width = 1111
    height = 888
    num = 10000
    gen_header(width, height)
    for _ in range(num):
        gen_random_rect(width, height)
    print("</svg>")


gen()
